﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>AngularJS 表单</title>
    <script type="text/javascript" src="Scripts/angular.js"></script>
</head>
<body>
    <div ng-app="myApp" ng-controller="formCtrl">
        <form novalidate>
            <!-- novalidate 属性是在 HTML5 中新增的。禁用了使用浏览器的默认验证。 -->
            First Name:<br>
            <input type="text" ng-model="user.firstName"><br>
            Last Name:<br>
            <input type="text" ng-model="user.lastName">
            <br><br>
            <button ng-click="reset()">RESET</button>
        </form>
        <p>form = {{user}}</p>
        <p>master = {{master}}</p>
    </div>

    <script>
        var app = angular.module('myApp', []);
        app.controller('formCtrl', function ($scope) {
            $scope.master = { firstName: "John", lastName: "Doe" };
            $scope.reset = function () {
                $scope.user = angular.copy($scope.master);
            };
            $scope.reset();
        });
    </script>

</body>
</html>